import { axios } from "../utils/request";

const api = {
  PageListUser: "/sysUser/user/page",
  SimplList: "/sysUser/user/List",
  Save: "/sysUser/user/save",
  Delete: "/sysUser/user/delete",
  UserList: "/sysUser/user/checkUserList",
  ResetPassword: "/sysUser/user/resetPassword", //初始化密码
  UpdateSysManager: "/sysUser/user/updateSysManager", //更换管理员
  SaveUserRole: "/sysUser/user/saveUserRole", //保存用户角色
  register: "/auth/user/register", //用户注册 
  checkUser: "/auth/user/checkUser", 
  sendUserCode: "/auth/user/sendUserCode", //发送注册手机验证码
  sendForgetPwdCode: "/auth/user/sendForgetPwdCode", //发送忘记密码手机验证码
  sendEntryCode: "/auth/user/sendEntryCode", //发送入职手机验证码
  resetPwd: "/auth/user/resetPwd", //重置密码
  entryRegister: "/auth/user/entryRegister", //用户入职
  checkEntryPhone: "/auth/entry/checkUserPhone", //校验入职手机号
  getDataScopeUsers: "/sysUser/user/getDataScopeUsers", //获取 当前用户 的数据权限用户
  pageMember: "/sysUser/user/pageMember" //个人租户
};

/**
 * 获取用户列表
 * parameter: {
 *     name: '',
 *     menuType: 1
 * }
 * @param parameter
 * @returns {*}
 */
export function PageListUser(parameter) {
  return axios({
    url: api.PageListUser,
    method: "get",
    params: parameter
  });
}

/**
 * 新增/修改用户
 * @param {*} data
 */
export function Save(data) {
  console.log(data);
  return axios({
    url: api.Save,
    method: "post",
    data: data
  });
}

/**
 * 删除用户
 */
export function Delete(id) {
  console.log(id)
  return axios({
    url: api.Delete,
    method: "DELETE",
    params: id
  });
}

/**
 * 获取授权用户
 */
export function UserList(roleId) {
  return axios({
    url: api.UserList,
    method: "get",
    params: roleId
  });
}

/**
 * 重置密码
 */
export function ResetPassword(data) {
  return axios({
    url: api.ResetPassword,
    method: "post",
    data: data
  });
}

/**
 * 更换管理员
 */
export function UpdateSysManager(data) {
  return axios({
    url: api.UpdateSysManager,
    method: "get",
    params: data
  });
}

/**
 * 分配角色
 */
export function SaveUserRole(data) {
  return axios({
    url: api.SaveUserRole,
    method: "post",
    data: data
  });
}

/**
 * 注册用户
 */
export function register(data) {
  return axios({
    url: api.register,
    timeout: 10000,
    method: 'post',
    data: data
  });
}

/**
 * 校验用户
 */
export function checkUser(data) {
  return axios({
    url: api.checkUser,
    method: "get",
    params: data
  });
}

/**
 * 发送注册手机验证码
 */
export function sendUserCode(data) {
  return axios({
    url: api.sendUserCode,
    method: "get",
    params: data
  });
}

/**
 * 发送重置密码手机验证码
 */
export function sendForgetPwdCode(data) {
  return axios({
    url: api.sendForgetPwdCode,
    method: "get",
    params: data
  });
}

/**
 * 发送入职手机验证码
 */
export function sendEntryCode(data) {
  return axios({
    url: api.sendEntryCode,
    method: "get",
    params: data
  });
}

/**
 * 重置密码
 */
export function resetPwd(data) {
  return axios({
    url: api.resetPwd,
    method: "post",
    data: data
  });
}

/**
 * 入职注册
 */
export function entryRegister(data) {
  return axios({
    url: api.entryRegister,
    method: "post",
    data: data
  });
}

/**
 * 检查入职手机号
 */
export function checkEntryPhone(data) {
  return axios({
    url: api.checkEntryPhone,
    method: "get",
    params: data
  });
}

/**
 * 获取 当前用户 的数据权限用户
 * @param {*} data 
 */
export function getDataScopeUsers(data) {
  return axios({
    url: api.getDataScopeUsers,
    method: "get",
    params: data
  });
}

/**
 * 个人租户
 */
export function pageMember(data) {
  return axios({
    url: api.pageMember,
    params: data
  });
}